package cn.codergege.demo

import cn.codergege.demo.bean.Greeter
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.core.env.Environment
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.context.junit.jupiter.SpringExtension
import javax.sql.DataSource

@ExtendWith(SpringExtension::class)
@SpringBootTest
@ActiveProfiles("test")
class BootstrapDemoApplicationTest {

    @Autowired
    lateinit var greeter: Greeter
    @Autowired
    lateinit var dateSource: DataSource
    @Autowired
    lateinit var env: Environment

    @Test
    fun testApp() {
        println("测试...")
        assertTrue(true)
        println(dateSource::class.java)
        println(env.activeProfiles)
    }

    @Test
    fun testGreeter() {
        assertEquals("This is test environment", greeter.greetingMsg)
    }
}
